package com.nhjf.service.impl.followThePainting;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nhjf.command.comment.CreateFollowThePaintingCommentCommand;
import com.nhjf.dao.followThePainting.FollowThePaintingCommentDao;
import com.nhjf.dao.followThePainting.FollowThePaintingDao;
import com.nhjf.model.finetTalk.FinetTalkComment;
import com.nhjf.model.followThePainting.FollowThePaintingComment;
import com.nhjf.model.system.User;
import com.nhjf.pojo.dto.result.ServiceResultDto;
import com.nhjf.pojo.qo.followThePainting.FollowThePaintingCommentQo;
import com.nhjf.service.followThePainting.FollowThePaintingCommentService;
import com.nhjf.service.followThePainting.FollowThePaintingService;
import com.nhjf.service.impl.BaseServiceImpl;

@Transactional
@Service("followThePaintingCommentService")
public class FollowThePaintingCommentServiceImpl extends BaseServiceImpl<FollowThePaintingComment, FollowThePaintingCommentQo, FollowThePaintingCommentDao> implements FollowThePaintingCommentService{

	@Autowired
	private FollowThePaintingCommentDao followThePaintingCommentDao;
	@Override
	protected FollowThePaintingCommentDao getDao() {
		// TODO Auto-generated method stub
		return followThePaintingCommentDao;
	}
	@Override
	public ServiceResultDto createFollowThePaintingComment(
			CreateFollowThePaintingCommentCommand createFollowThePaintingCommentCommand) {
		// TODO Auto-generated method stub
		ServiceResultDto resultDto = new ServiceResultDto();
		FollowThePaintingComment followThePaintingComment=new FollowThePaintingComment();
		if(StringUtils.isEmpty(createFollowThePaintingCommentCommand.getComment())) {
			resultDto.setSuccess(false);
			resultDto.setResultMessage("评论内容为空");
		}
		followThePaintingComment.setComment(createFollowThePaintingCommentCommand.getComment());
		followThePaintingComment.setCommentTime(new Date());
		followThePaintingComment.setCommentType(createFollowThePaintingCommentCommand.getCommentType());
		followThePaintingComment.setCommentUserType(createFollowThePaintingCommentCommand.getCommentUserType());
		followThePaintingComment.setFollowThePaintingId(createFollowThePaintingCommentCommand.getFollowThePaintingId());
		User user=new User();
		user.setId(createFollowThePaintingCommentCommand.getUserId());
		followThePaintingComment.setUser(user);
		followThePaintingCommentDao.save(followThePaintingComment);
		resultDto.setSuccess(true);
		resultDto.setResultMessage("评论成功");
		return resultDto;
	}

}
